<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
	<head>
		<title><?php echo TITREBO ?> - <?php echo trad($this -> titre, APPLNG) ?></title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="description" content="" />
		<meta name="keywords" content="" />
		<meta name="author" content="webz0ne 1996 - <?php echo date('Y') ?>" />
		<link rel="shortcut icon" href="<?php echo URL_SITE ?>img/cdg.ico" type="image/x-icon" />
		<script>
			var pagetpl = '<?php echo $GLOBALS["page"] ?>';
			var applng = '<?php echo APPLNG ?>';
			var pathToImages = '<?php echo URL_SITE ?>img/';
		</script>
		<link type="text/css" rel="stylesheet" media="all" href="<?php echo URL_SITE ?>css/css.php?<?php echo time() ?>" />
		<link href="<?php echo URL_SITE ?>css/dhtmlgoodies_calendar.css?<?php echo time() ?>" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js?<?php echo time() ?>"></script>
		<script type="text/javascript" src="<?php echo URL_SITE ?>js/js.php?<?php echo time() ?>"></script>
		<script src="<?php echo URL_SITE ?>js/dhtmlgoodies_calendar.js?<?php echo time() ?>" type="text/javascript"></script>
	</head>
	<body>
		<form id="chnlng" method="post" action="<?php echo URL_SITE ?>">
			<input type="hidden" id="redir" name="redir" value="<?php echo REQUESTURI ?>" />
			<input type="hidden" id="setlng" name="setlng" value="" />
			<input type="hidden" id="oldlng" name="oldlng" value="<?php echo APPLNG ?>" />
		</form>
		<div id="header">
			<div id="headercontenu">
				<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td width="50%"  style="text-align: left;" valign="middle">
						<a href="<?php echo URL_SITE ?>">
							<img src="<?php echo URL_SITE ?>img/cdg.png" alt="<?php echo TITREBO ?>" title="<?php echo TITREBO ?>" border="0" />
						</a>
						<br />
						<span onclick="go('<?php echo URL_SITE ?>');" class="bologo">
							<img src="<?php echo URL_SITE ?>?blackttf=1&txt=BACKOFFICE&tp=18" alt="BACKOFFICE" title="BACKOFFICE" />
						</span>
					</td>
					<td width="50%" style="text-align: right;">
						<img src="<?php echo URL_SITE ?>img/drapeaux/fr.png" alt="<?php echo trad('Français', APPLNG) ?>" title="<?php echo trad('Français', APPLNG) ?>" style="cursor: pointer; visibility: <?php if (APPLNG <> 'fr'): ?>visible<?php else: ?>hidden<?php endif; ?>;" onclick="changelng('fr');" />&nbsp;
						<img src="<?php echo URL_SITE ?>img/drapeaux/gb.png" alt="<?php echo trad('Anglais', APPLNG) ?>" title="<?php echo trad('Anglais', APPLNG) ?>" style="cursor: pointer; visibility: <?php if (APPLNG <> 'en'): ?>visible<?php else: ?>hidden<?php endif; ?>;" onclick="changelng('en');" />&nbsp;
						<img src="<?php echo URL_SITE ?>img/drapeaux/de.png" alt="<?php echo trad('Allemand', APPLNG) ?>" title="<?php echo trad('Allemand', APPLNG) ?>" style="cursor: pointer; visibility: <?php if (APPLNG <> 'de'): ?>visible<?php else: ?>hidden<?php endif; ?>;" onclick="changelng('de');" />&nbsp;
						<img src="<?php echo URL_SITE ?>img/drapeaux/es.png" alt="<?php echo trad('Espagnol', APPLNG) ?>" title="<?php echo trad('Espagnol', APPLNG) ?>" style="cursor: pointer; visibility: <?php if (APPLNG <> 'es'): ?>visible<?php else: ?>hidden<?php endif; ?>;" onclick="changelng('es');" />
						<?php if(get_s("bo_user") > 0): ?>
						<br />
						<?php if ($GLOBALS["page"] <> 'accueil' && $GLOBALS["page"] <> 404):  ?>
						<a href="<?php echo rw('accueil') ?>"><?php echo trad('Tableau de bord', APPLNG) ?></a>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<?php endif; ?>
						<a href="<?php echo URL_SITE ?>?logout=1"><?php echo trad('Se déconnecter', APPLNG) ?></a>
						<?php endif; ?>
					</td>
				</tr>
				</table>
			</div>
		</div>
		<div class="sep"></div>
		<div id="contenu">
<?php if (!$this -> habilitation): ?>
	<div class="sep"></div>
	<div class="msg msg-erreur">
		<p>
			<?php echo trad('Vous n\'avez pas les habilitations suffisantes pour afficher cette page.', APPLNG) ?>
		</p>
	</div>
<?php else: ?>
	<?php if($this -> erreur_table): ?>
	<div class="sep"></div>
	<div class="msg msg-erreur">
		<p>
			<?php echo trad('La table ' . $this -> table . ' n\'est pas correctement configurée.', APPLNG) ?>
		</p>
	</div>
	<?php exit; ?>
	<?php endif; ?>
	<img src="<?php echo URL_SITE ?>?titrettf=1&txt=<?php echo trad($this -> titre, APPLNG) ?>" alt="<?php echo trad($this -> titre, APPLNG) ?>" title="<?php echo trad($this -> titre, APPLNG) ?>" /><p />
	<?php if($this -> gridhtml["vide"]): ?>
			<div class="sep"></div>
			<div class="msg msg-erreur">
				<p>
					<?php if (!strlen(get_s('requete_' . $this -> table))): ?>
						<?php echo trad('Aucun enregistrement à afficher.', APPLNG) ?>
					<?php else: ?>
						<?php echo trad('Aucun enregistrement ne correspond à la requête.', APPLNG) ?>
						<br >
						<a href="<?php echo rw($this -> page, 'table=' . $this -> table . '&delfiltre=1') ?>"><?php echo trad('Effectuer une autre requête.', APPLNG) ?></a>
					<?php endif; ?>
				</p>
			</div>
		<?php else: ?>
		<script>
			var cle = '<?php echo md5(get_s('bo_user') . $this -> table . date('dmY')) ?>';
			var champs = new Array();
			var champs_id = new Array();
			var champs_type = new Array();
			var champs_type_select = new Array();
			var champs_data = new Array();
			<?php foreach ($this -> get_filtre as $tmpchmp): ?>
				champs.push('<?php echo $tmpchmp['nom'] ?>');
				champs_id.push('<?php echo $tmpchmp['id'] ?>');
				champs_type.push('<?php echo $tmpchmp['type'] ?>');
				champs_type_select.push('<?php echo $tmpchmp['typeselect'] ?>');
				champs_data.push('<?php echo $tmpchmp['data'] ?>');
			<?php endforeach; ?>
			
			function addfiltre()
			{
				var index = document.getElementById('nbfiltre').value;
				document.getElementById('nbfiltre').value = parseInt(index) + 1;
				var NouvelleLigne = document.getElementById('tablefiltre').insertRow(index);
				NouvelleLigne.setAttribute('id', 'tr_filtre_' + index);
				
				var NouvelleCellule;
				
				// td1
				NouvelleCellule = NouvelleLigne.insertCell(0);
				NouvelleCellule.setAttribute('id', 'td1_filtre_' + index);
				
				var td1html = '<select id="filtre_' + index + '" onchange="champfiltre(' + index + ');"><option><?php echo trad('Choisir', APPLNG) ?></option>';
				
				for (var i = 0 ; i < champs.length ; i++)
					td1html += '<option value="' + champs_id[i] + '">' + champs[i] + '</option>' + "\n";
				
				NouvelleCellule.innerHTML = td1html;
		
				// td2
				NouvelleCellule = NouvelleLigne.insertCell(1);
				NouvelleCellule.setAttribute('id', 'td2_filtre_' + index);
				var td2html = '<select id="op_' + index + '"><option value="=">&#61;</option><option value="LIKE"><?php echo trad('contient', APPLNG) ?></option><option value=">">&gt;</option><option value="<">&lt;</option><option value=">=">&gt;&#61;</option><option value="<=">&lt;&#61;</option><option value="<>">&#33;&#61;</option></select>';
				NouvelleCellule.innerHTML = td2html;
				
				// td3
				NouvelleCellule = NouvelleLigne.insertCell(2);
				NouvelleCellule.setAttribute('id', 'tdfiltre_' + index);
				var td3html = '';
				NouvelleCellule.innerHTML = td3html;
				
				// td4
				NouvelleCellule = NouvelleLigne.insertCell(3);
				NouvelleCellule.setAttribute('id', 'supp_' + index);
				document.getElementById('supp_'+index).style.display = 'none';
				var td4html = '<a href="#" onclick="suppfiltre(' + index + '); return false;"><img src="<?php echo URL_SITE ?>img/delete.png" /></a>';
				NouvelleCellule.innerHTML = td4html;

			}
			
			function get_index(id)
			{
				for (var i = 0 ; i < champs_id.length ; i++)
				{
					if (champs_id[i] == id)
						return i;
				}
				return "";
			}
			
			function champfiltre(id)
			{
				var html;
				var val = $('#filtre_' + id).val();
				var index = get_index(val);
				var type = champs_type[index];
				if (type == 'select')
				{
					var type_select = champs_type_select[index];
					var data = champs_data[index];
				}
				if (type == 'input')
					html = '<input id="rec_' + id + '" size="15" />';
				else if (type == 'date')
					html = '<input id="rec_' + id + '" size="15" />&nbsp;&nbsp;&nbsp;<img style="position: relative; top: 4px; cursor: pointer;" onclick="displayCalendar(document.getElementById(\'rec_' + id + '\'),\'dd/mm/yyyy\',this);" src="<?php echo URL_SITE ?>img/calendrier.gif" title="<?php echo trad('Choisir une date', APPLNG) ?>" alt="<?php echo trad('Choisir une date', APPLNG) ?>" id="imgdate_' + id + '" />';
				else if (type == 'select')
				{
					var options = '';
					if (type_select == 'vocabulaire')
					{
						var tab = data.split(';');
						for (var i = 0 ; i < tab.length ; i++)
						{
							var seg = tab[i].split('%%');
							var cle = seg[0];
							var val = seg[1];
							options += '<option value="' + cle + '">' + val + '</option>' + "\n";
						}
						html = '<select id="rec_' + id + '">' + options + '</select>';
					}
					
					else if (type_select == 'sql')
					{
						var requete = data;
						var datas = sql(requete);
						var tab = datas.split(';');
						for (var i = 0 ; i < tab.length ; i++)
						{
							var seg = tab[i].split('%%');
							var cle = seg[0];
							var val = seg[1];
							options += '<option value="' + cle + '">' + val + '</option>' + "\n";
						}
						html = '<select id="rec_' + id + '">' + options + '</select>';
					}
				}

				
				$('#tdfiltre_' + id).html(html);
				$('#supp_' + id).show();

			}
			
			function suppfiltre(id)
			{
				var del = $('#filtredel').val();
				if (del.length > 0)
					document.getElementById('filtredel').value = del + ',' + id;
				else
					document.getElementById('filtredel').value = id;
				$('#tr_filtre_' + id).hide(500);
			}
			
			function validfiltre()
			{
				var index = $('#nbfiltre').val();
				var del = $('#filtredel').val();
				
				var bad = del.split(',');
				var good = '';
				
				if (index > 1)
				{		
					for (var i = 0 ; i < index ; i++)
					{
						if (del.length > 0)
						{
							if (!in_array(i, bad))
								good += i + ',';
						}
						else
							good += i + ',';
					}
					var tab = good.split(',');
				}
				
				else
				{
					var tab = new Array();
					tab[0] = 0;
					tab[1] = 1;
				}
				
				var requete = "";		
				
				for (var i = 0 ; i < (tab.length - 1) ; i++)
				{
					var id = tab[i];
					
					var champ = $('#filtre_' + id).val();
					var op = $('#op_' + id).val();
					
					if (!document.getElementById('rec_' + id))
					{
						alert("<?php echo trad('Le filtrage n\'est pas correct, merci de le corriger.', APPLNG) ?>");
						return false;
					}
					
					var cond = $('#rec_' + id).val();
					
					if (cond.length < 1 || cond == 'undefined')
					{
						alert("<?php echo trad('Le filtrage n\'est pas correct, merci de le corriger.', APPLNG) ?>");
						return false;
					}
					
					requete += champ + '$$' + op + '$$' + '***' + cond + '***';
					if (i < (tab.length - 2))
						requete += '%%';
				}

				document.getElementById('requete').value = requete;
				document.getElementById('formrequete').submit();
			}
			
			function del(id, table)
			{
				if (confirm('<?php echo trad('Souhaitez-vous vraiment supprimer cet enregistrement ?', APPLNG) ?>'))
				{
					var url = 'index.php?del=1&delid='+id+'&deltable='+table+'&delcle=' + cle;
					var methode = 'GET';
					var res = Get_HTML(url, methode);
					if (res == 'OK')
					{
						alert('<?php echo trad('L\enregistrement a été correctement effacé.', APPLNG) ?>');
						document.location.href = document.URL;
					}
					else
					{
						alert('<?php echo trad('une erreur est survenue lors de l\effacement, merci de recommencer.', APPLNG) ?>');
						return false;
					}
				}
			}


		</script>
		<img alt="<?php echo trad('Ajouter un nouvel enregistrement') ?>" title="<?php echo trad('Ajouter un nouvel enregistrement') ?>" src="<?php echo URL_SITE ?>img/add.png" style="position: relative; top: 5px;" />&nbsp;&nbsp;<a href="<?php echo rw('add', 'table=' . $this -> table) ?>"><?php echo trad('Ajouter un nouvel enregistrement') ?></a>
		<div class="sep"></div>
		<?php if (!strlen(get_s('requete_' . $this -> table))): ?>
		<form id="formrequete" action="<?php echo URL_SITE ?>" method="POST">
			<input type="hidden" value="<?php echo $this -> page ?>" name="<?php echo NOMPAGE ?>" />
			<input type="hidden" value="<?php echo $this -> table ?>" name="table" />
			<input type="hidden" value="1" name="delcache" />
			<input type="hidden" value="" name="requete" id="requete" />
		</form>

		<input id="nbfiltre" type="hidden" value="0" />
		<input id="filtredel" type="hidden" value="" />
		<input id="lastligne" type="hidden" value="0" />
		
		<span onclick="aff_filtre();" style="cursor: pointer;" id="spanfiltre"><img src="<?php echo URL_SITE ?>img/filtrer.gif" /> <span id="titre_filtre"><?php echo trad('Ajouter un filtre') ?></span></span>
		<div class="sep"></div>
		<div id="filtre">
			<table id="tablefiltre">
			</table>
			<div class="sep"></div>
			<img id="addpng" style="cursor: pointer;" src="<?php echo URL_SITE ?>img/add.png" onclick="addfiltre();" />&nbsp;&nbsp;&nbsp;<img id="okpng" style="cursor: pointer;" src="<?php echo URL_SITE ?>img/ok.jpg" onclick="validfiltre();" />
			<div class="sep"></div>
		</div>
		<?php else: ?>
			<img style="position: relative; top: 5px;" src="<?php echo URL_SITE ?>img/filtredelete.png" alt="<?php echo trad('Supprimer le filtre actuel.', APPLNG) ?>" title="<?php echo trad('Supprimer le filtre actuel.', APPLNG) ?>" />&nbsp;&nbsp;<a href="<?php echo rw($this -> page, 'table=' . $this -> table . '&delfiltre=1') ?>"><?php echo trad('Supprimer le filtre actuel', APPLNG) ?></a>
			<div class="sep"></div>
			<div class="msg msg-info">
				<p>
					<strong><?php echo trad('Filtre actuel', APPLNG) ?></strong>
					<br />
					<?php echo aff_filtre(get_s('requete_' . $this -> table)); ?>
				</p>
			</div>
			<div class="sep"></div>
		<?php endif; ?>
		<strong><?php echo $this -> gridhtml['total'] ?> <?php if($this -> gridhtml['total'] < 2): ?><?php echo trad('Enregistrement', APPLNG) ?><?php else: ?><?php echo trad('Enregistrements', APPLNG) ?><?php endif; ?></strong>
			<p />
			<?php if($this -> gridhtml["pages"] > 1): ?>
				<!-- Pagination !-->
				<?php echo GP_fonctions::pagination(array(NOMPAGE => $this -> page, 'table' => $this -> table, 'tri' => $this -> gridhtml['tri'], 'ordre' => $this -> gridhtml['ordre']), $this -> gridhtml['numpage'], $this -> gridhtml['total'], $this -> gridhtml['limite']) ?>
				<p />
			<?php endif; ?>
			<table class="liste">
			<thead>
			<tr>
			<?php foreach($this -> gridhtml['affichage'] as $champ => $nom_affiche): ?>
				<?php if($champ == $this -> gridhtml['tri']): ?>
					<?php $ordre_rw = $this -> gridhtml["autre_ordre"]; ?>
				<?php else: ?>
					<?php $ordre_rw = 'ASC'; ?>
				<?php endif; ?>
				<th style="text-align: center;"><?php if(in_array($champ, $this -> gridhtml['champs_tri'])): ?><a class="blanc" href="<?php echo rw($this -> page, 'table=' . $this -> table . '&numpage='.$this -> gridhtml['numpage'].'&tri='.$champ.'&ordre=' . $ordre_rw) ?>"><?php endif; ?><?php echo $nom_affiche ?><?php if(in_array($champ, $this -> gridhtml['champs_tri'])): ?></a><?php endif; ?><?php if($champ == $this -> gridhtml['tri']): ?>&nbsp;&nbsp;<img src="<?php echo URL_SITE ?>img/sort_<?php echo strtolower($this -> gridhtml['ordre']) ?>.png" alt="<?php echo $this -> gridhtml['ordre'] ?>" title="<?php echo $this -> gridhtml['ordre'] ?>" style="position: relative; top: 3px;" /><?php endif; ?></th>
			<?php endforeach; ?>
				<th width="100px">&nbsp;</th>
			</tr>
			</thead>
			<tbody>
			<?php $i = 0; ?>
			<?php foreach($this -> gridhtml["res"] as $ligne): ?>
			<tr class="<?php if ($i++ % 2 <> 0): ?>im<?php endif; ?>pair">
			<?php foreach($this -> gridhtml['affichage'] as $champ => $nom_affiche): ?>
				<?php if(strlen($this -> gridhtml['php'])): 
					eval($this -> gridhtml['php']); 
				endif; ?>
				<td><?php echo $ligne[$champ] ?></td>
			<?php endforeach; ?>
				<td style="text-align: center">
					<a href="<?php echo rw('view', 'table=' . $this -> table . '&id='.$ligne[$this -> gridhtml['id']].'&cle=' . make_cle('view', $this -> table, $ligne[$this -> gridhtml['id']])) ?>"><img src="<?php echo URL_SITE ?>img/view.png" alt="<?php echo trad('Afficher', APPLNG) ?>" title="<?php echo trad('Afficher', APPLNG) ?>" border="0" /></a>
					&nbsp;
					<a href="<?php echo rw('dup', 'table=' . $this -> table . '&id='.$ligne[$this -> gridhtml['id']].'&cle=' . make_cle('dup', $this -> table, $ligne[$this -> gridhtml['id']])) ?>"><img src="<?php echo URL_SITE ?>img/grid/duplicate.png" alt="<?php echo trad('Dupliquer', APPLNG) ?>" title="<?php echo trad('Dupliquer', APPLNG) ?>" border="0" /></a>
					&nbsp;
					<a href="<?php echo rw('edit', 'table=' . $this -> table . '&id='.$ligne[$this -> gridhtml['id']].'&cle=' . make_cle('edit', $this -> table, $ligne[$this -> gridhtml['id']])) ?>"><img src="<?php echo URL_SITE ?>img/edit.png" alt="<?php echo trad('Editer', APPLNG) ?>" title="<?php echo trad('Editer', APPLNG) ?>" border="0" /></a>
					&nbsp;
					<img style="cursor: pointer;" onclick="del('<?php echo $ligne[$this -> gridhtml['id']] ?>', '<?php echo $this -> table ?>')" src="<?php echo URL_SITE ?>img/delete.png" alt="<?php echo trad('Supprimer', APPLNG) ?>" title="<?php echo trad('Supprimer', APPLNG) ?>" border="0" />
				</td>
			</tr>
			<?php endforeach; ?>
			</tbody>
			</table>
			<?php if($this -> gridhtml["pages"] > 1): ?>
				<p />
				<!-- Pagination !-->
				<?php echo GP_fonctions::pagination(array(NOMPAGE => $this -> page, 'table' => $this -> table, 'tri' => $this -> gridhtml['tri'], 'ordre' => $this -> gridhtml['ordre']), $this -> gridhtml['numpage'], $this -> gridhtml['total'], $this -> gridhtml['limite']) ?>
			<?php endif; ?>
			<div class="sep"></div>
			<div style="text-align: right">
				<u><strong><?php echo trad('Exporter', APPLNG) ?></strong></u>
				&nbsp;&nbsp;&nbsp;
				<a href="<?php echo rw($this -> page, 'table=' . $this -> table . '&export_bo=1&type_export_bo=xls') ?>"><img border="0" src="<?php echo URL_SITE ?>/img/xls.png" title="Excel" alt="Excel" /></a>
				&nbsp;&nbsp;&nbsp;
				<a href="<?php echo rw($this -> page, 'table=' . $this -> table . '&export_bo=1&type_export_bo=pdf') ?>"><img border="0" src="<?php echo URL_SITE ?>/img/pdf.png" title="PDF" alt="PDF" /></a>
			</div>
			<div class="sep"></div>
			<img style="position: relative; top: 5px;" src="<?php echo URL_SITE ?>img/back.png" alt="<?php echo trad('Retour', APPLNG) ?>" title="<?php echo trad('Retour', APPLNG) ?>" />&nbsp;&nbsp;<a href="<?php echo $this -> retour_url ?>"><?php echo trad('Retour', APPLNG) ?></a>
	<?php endif; ?>
<?php endif; ?>		</div>
		<div class="sep"></div>
		<div id="footer">
			<div id="footercontenu">
				<img style="position: relative; top: 5px;" src="<?php echo URL_SITE ?>?blackttf=1&txt=© 2011<?php if(date("Y") > 2011): ?> - <?php echo date("Y") ?><?php endif; ?> - Comme des Garçons&tp=11" alt="COPYRIGHT" title="COPYRIGHT" />
			</div>
		</div>
  </body>
</html>